﻿using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;
using PrivateTracker.Service.Application;

namespace PrivateTracker.Service.Web.Entry.Controllers
{
    /// <summary>
    /// Torrent相关
    /// </summary>
    [ApiDescriptionSettings(Name = "Torrent", Order = 10000)]
    public class TorrentController : IDynamicApiController
    {
        private readonly ITorrentService _torrentService;
        private readonly ISysFileService _sysFileService;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="torrentService"></param>
        public TorrentController(ITorrentService torrentService, ISysFileService sysFileService)
        {
            _torrentService = torrentService;
            _sysFileService = sysFileService;
        }
        /// <summary>
        /// 发布资源
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/torrent/add")]
        public async Task<TorrentOutput> AddAsync([FromForm] TorrentInput input)
        {
            return await _torrentService.AddAsync(input);
        }
        /// <summary>
        /// 删除资源 
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("/torrent/delete")]
        public async Task DeleteAsync(DeleteTorrentInput input)
        {
            await _torrentService.DeleteAsync(input);
        }
        /// <summary>
        /// 资源详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("/torrent/detail")]
        public async Task<dynamic> DetailAsync(long id)
        {
            return await _torrentService.GetAsync(id);
        }
        /// <summary>
        /// 下载种子
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("/torrent/downloadTorrent")]
        public async Task<dynamic> DownloadAsync([FromQuery] QueryFileInfoInput input)
        {
            return await _torrentService.DownloadTorrent(input);
        }
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("/torrent/page")]
        public async Task<dynamic> QueryTorrentPageList([FromQuery] TorrentPageInput input)
        {
            return await _torrentService.QueryTorrentPageList(input);
        }

    }
}
